unit DeleteData;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Edit, RzPanel, ExtCtrls, RzDlgBtn, StdCtrls, Mask, RzEdit,
  RzLabel, DateUtils;

type
  TDeleteDataFrm = class(TEditFrm)
    dtFrom: TRzDateTimeEdit;
    RzLabel1: TRzLabel;
    RzLabel2: TRzLabel;
    procedure RzDialogButtons1ClickCancel(Sender: TObject);
    procedure RzDialogButtons1ClickOk(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  DeleteDataFrm: TDeleteDataFrm;

implementation

uses DM;

{$R *.dfm}


procedure TDeleteDataFrm.RzDialogButtons1ClickCancel(Sender: TObject);
begin
  inherited;
  Close;
end;

procedure TDeleteDataFrm.RzDialogButtons1ClickOk(Sender: TObject);
var
  dtStart, dtEnd: Tdatetime;
  AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond: Word;
begin
  inherited;
  try
    dtStart := dtFrom.Date;
    dmMain.qryDelete.Close;
    dmMain.qryDelete.SQL.Clear;
    dmMain.qryDelete.SQL.Add('delete  from OneMeter where  (SaveDate < :@BeginDate)');
    dmMain.qryDelete.Parameters.ParamByName('@BeginDate').Value := dtStart;
    dmMain.qryDelete.ExecSQL;

    dmMain.qryDelete.Close;
    dmMain.qryDelete.SQL.Clear;
    dmMain.qryDelete.SQL.Add('delete  from TwoMeter where  (SaveDate < :@BeginDate)');
    dmMain.qryDelete.Parameters.ParamByName('@BeginDate').Value := dtStart;
    dmMain.qryDelete.ExecSQL;

    dmMain.qryDelete.Close;
    dmMain.qryDelete.SQL.Clear;
    dmMain.qryDelete.SQL.Add('delete  from AvgMeter where  (SaveDate < :@BeginDate)');
    dmMain.qryDelete.Parameters.ParamByName('@BeginDate').Value := dtStart;
    dmMain.qryDelete.ExecSQL;
  except


  end;
end;

procedure TDeleteDataFrm.FormShow(Sender: TObject);
var
  dmTime: TDateTime;
begin
  inherited;
  dtFrom.Date := Date;
end;

end.
